package com.company.project.web;
import com.company.project.core.Result;
import com.company.project.core.ResultGenerator;
import com.company.project.model.Navigation;
import com.company.project.service.NavigationService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* Created by CodeGenerator on 2018/10/08.
*/
@RestController
@RequestMapping("/navigation")
public class NavigationController {
    @Resource
    private NavigationService navigationService;

    @PostMapping("/add")
    public Result add(Navigation navigation) {
        navigationService.save(navigation);
        return ResultGenerator.genSuccessResult();
    }

    @PostMapping("/delete")
    public Result delete(@RequestParam Integer id) {
        navigationService.deleteById(id);
        return ResultGenerator.genSuccessResult();
    }

    @PostMapping("/update")
    public Result update(Navigation navigation) {
        navigationService.update(navigation);
        return ResultGenerator.genSuccessResult();
    }

    @PostMapping("/detail")
    public Result detail(@RequestParam Integer id) {
        Navigation navigation = navigationService.findById(id);
        return ResultGenerator.genSuccessResult(navigation);
    }

    @GetMapping("/list")
    public Result list() {
        return ResultGenerator.genSuccessResult(navigationService.getNavigation());
    }
}
